#ifndef QQ_EMOJI_MODEL
#define QQ_EMOJI_MODEL

#include <qabstractitemmodel.h>
#include <qcontiguouscache.h>
#include <qmovie.h>

#include <rlottie.h>

#include "core/QQConfig.h"

class QQEmojiModel : public QAbstractListModel
{
	Q_OBJECT
public:
	QQEmojiModel(QObject* parent = nullptr);
	~QQEmojiModel();

	void addEmoji(const QQChatEmoji& emoji);
	void addEmojis(const QList<QQChatEmoji>& emojis);

	QString getEmojiPreview(long id);

	int getMovieFrameCount(long id);
	QImage getMovieFrame(long id, int index, int width, int height);
	int getLottieFrameCount(long id);
	QImage getLottieFrame(long id, int index, int width, int height);

	int rowCount(const QModelIndex& parent = QModelIndex()) const;
	QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
private:
	QContiguousCache<QQChatEmoji*> mEmojis;
	QMovie* mMovie;
	std::unique_ptr<rlottie::Animation> mLottie;
	QString mCurrentPath;
};

#endif // QQ_EMOJI_MODEL